

% galois.sty
\@ifundefined{documentclass}%
{% LaTeX209
\@latexerr{Please use obsolete "galois209.sty"}\@ehd
}% LaTeX209
{% LaTeX2e
\ProvidesPackage{galois}[1997/05/19 v1.0 LaTeX2e package for Galois connections]
\typeout{LaTeX2e package for Galois connections, v1.0, 1997/05/19, P. Cousot}
}% LaTeX2e
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \comp = o (functional composition)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\comp}{\mathchoice{\mathrel{\raisebox{0.2ex}{$\scriptstyle\circ$}}}%
{\mathrel{\raisebox{0.2ex}{$\scriptstyle\circ$}}}%
{\mathrel{\raisebox{0.1ex}{$\scriptscriptstyle\circ$}}}%
{\mathrel{\raisebox{0.1ex}{$\scriptscriptstyle\circ$}}}}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \galois{a}{b}, \Galois{a}{b}, \galoiS{a}{b}, \GaloiS{a}{b}
% \GaloisStyle  : style of a & b (\scripstyle by default)
% \GaloisSep    : distance between arrows and a, b (0.5ex by default)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\GaloisStyle{\scriptstyle}
\newlength{\GaloisSep}
\setlength{\GaloisSep}{0.5ex}
%
\def\@GALOISarrowheight{0.125ex}%0.5pt
\newlength{\@GALOISalphadepth}
\newlength{\@GALOISalphaheight}
\newlength{\@GALOISgammadepth}
\newlength{\@GALOISgammaheight}
\newlength{\@GALOISwidth}
\newlength{\@GALOISheight}
\newlength{\@GALOISdepth}
\newlength{\@GALOIStotalheight}
\newlength{\@GALOISGap}
\newlength{\@GALOISalphaarrowwidth}
\newlength{\@GALOISalphaarrowhalfheight}
\newlength{\@GALOISgammaarrowwidth}
\newlength{\@GALOISgammaarrowhalfheight}
%
% \Galois@put(x,y-d){text} : put text at coordinates (x,y-d), in
%                          a box of size 0pt x 0pt
%
\def\Galois@put(#1,#2-#3)#4{\rlap{\smash{\hskip#1\setlength{\@tempdimc}{#2}%
\addtolength{\@tempdimc}{-#3}\raisebox{\@tempdimc}{#4}}}}
%                                            g
% \@GALOIS{a}{g}{-->}{<--} : construct <------------
%                                       ------------>
%                                            a
\def\@GALOIS#1#2#3#4{\ensuremath{\mathrel{%
% compute width of alpha/lower and gamma/upper arrows
\settowidth{\@GALOISalphaarrowwidth}{${#3}$}%
\settowidth{\@GALOISgammaarrowwidth}{${#4}$}%
% compute half height of alpha/lower arrow
\settodepth{\@GALOISalphaarrowhalfheight}{${#3}$}%
\settoheight{\@tempdima}{${#3}$}%
\addtolength{\@GALOISalphaarrowhalfheight}{\@tempdima}%
\divide \@GALOISalphaarrowhalfheight by 2%
% compute half height of gamma/upper arrow
\settodepth{\@GALOISgammaarrowhalfheight}{${#4}$}%
\settoheight{\@tempdima}{${#4}$}%
\addtolength{\@GALOISgammaarrowhalfheight}{\@tempdima}
\divide \@GALOISgammaarrowhalfheight by 2%
% compute \@GALOISGap = max(\@GALOISalphaarrowhalfheight,\@GALOISgammaarrowhalfheight)+0.3ex
% which is the distance between the two arrows
\ifdim\@GALOISalphaarrowhalfheight>\@GALOISgammaarrowhalfheight%
\setlength{\@GALOISGap}{\@GALOISalphaarrowhalfheight}%
\else%
\setlength{\@GALOISGap}{\@GALOISgammaarrowhalfheight}%
\fi%
\addtolength{\@GALOISGap}{0.3ex}%
% compute width of the picture \@GALOISwidth
\ifdim\@GALOISalphaarrowwidth>\@GALOISgammaarrowwidth%
\settowidth{\@tempdima}{\mbox{\hspace*{\@GALOISalphaarrowwidth}$\GaloisStyle#1$}}%
\settowidth{\@tempdimb}{\mbox{\hspace*{\@GALOISalphaarrowwidth}$\GaloisStyle#2$}}%
\else%
\settowidth{\@tempdima}{\mbox{\hspace*{\@GALOISgammaarrowwidth}$\GaloisStyle#1$}}%
\settowidth{\@tempdimb}{\mbox{\hspace*{\@GALOISgammaarrowwidth}$\GaloisStyle#2$}}%
\fi%
\ifdim\@tempdima>\@tempdimb
\setlength{\@GALOISwidth}{\@tempdima}
\else
\setlength{\@GALOISwidth}{\@tempdimb}
\fi
% compute height \@GALOISheight depth \@GALOISdepth
% and total height \@GALOIStotalheight  of the picture
\settodepth{\@GALOISalphadepth}{$\GaloisStyle#1$}%
\settoheight{\@GALOISalphaheight}{$\GaloisStyle#1$}%
\settodepth{\@GALOISgammadepth}{$\GaloisStyle#2$}%
\settoheight{\@GALOISgammaheight}{$\GaloisStyle#2$}%
% compute depth \@GALOISdepth of the picture
% \@GALOISdepth =        \@GALOISalphadepth+\@GALOISalphaheight % vertical size of alpha tag
%                      + \GaloisSep                 % between tag and arrow 
\setlength{\@GALOISdepth}{\@GALOISalphadepth}%
\addtolength{\@GALOISdepth}{\@GALOISalphaheight}%
\addtolength{\@GALOISdepth}{\GaloisSep}%
% compute height \@GALOISheight of the picture
% \@GALOISheight =       \@GALOISGap                % gap between arrows
%                      + 2\@GALOISarrowheight       % height of 2 arrows
%                      + \GaloisSep                 % between tag and arrow 
%                      + \@GALOISgammadepth+\@GALOISgammaheight % vertical size of gamma tag
\setlength{\@GALOISheight}{\@GALOISGap}%
\addtolength{\@GALOISheight}{\GaloisSep}%
\addtolength{\@GALOISheight}{\@GALOISarrowheight}% height of alpha arrow
\addtolength{\@GALOISheight}{\@GALOISarrowheight}% height of gamma arrow
\addtolength{\@GALOISheight}{\@GALOISgammadepth}%
\addtolength{\@GALOISheight}{\@GALOISgammaheight}%
% compute  total height \@GALOIStotalheight of the picture
% \@GALOIStotalheight = \@GALOISdepth + \@GALOISheight
\setlength{\@GALOIStotalheight}{\@GALOISdepth}
\addtolength{\@GALOIStotalheight}{\@GALOISheight}
% put alpha arrow
\setlength{\@tempdimb}{\@GALOISalphadepth}
\addtolength{\@tempdimb}{\@GALOISalphaheight}%
\addtolength{\@tempdimb}{\GaloisSep}%
\Galois@put(0pt,\@tempdimb-\@GALOISdepth){\vrule height\@GALOISarrowheight width\@GALOISwidth depth0pt}%
% put alpha arrow head
\setlength{\@tempdima}{\@GALOISwidth}
\addtolength{\@tempdima}{-\@GALOISalphaarrowwidth}
\setlength{\@tempdimb}{\@GALOISalphadepth}
\addtolength{\@tempdimb}{\@GALOISalphaheight}%
\addtolength{\@tempdimb}{\GaloisSep}%
\addtolength{\@tempdimb}{-\@GALOISalphaarrowhalfheight}%
\setlength{\@tempdimc}{\@GALOISarrowheight}\divide\@tempdimc by 2
\addtolength{\@tempdimb}{-\@tempdimc}% correction to lift arrow 
\Galois@put(\@tempdima,\@tempdimb-\@GALOISdepth){${#3}$}%
% put gamma arrow
\setlength{\@tempdimb}{\@GALOISalphadepth}
\addtolength{\@tempdimb}{\@GALOISalphaheight}%
\addtolength{\@tempdimb}{\GaloisSep}%
\addtolength{\@tempdimb}{\@GALOISGap}%
\addtolength{\@tempdimb}{\@GALOISarrowheight}% height of alpha arrow 
\setlength{\@tempdimc}{\@GALOISarrowheight}\divide\@tempdimc by 2
\addtolength{\@tempdimb}{\@tempdimc}% correction to lift arrow 
\Galois@put(0pt,\@tempdimb-\@GALOISdepth){\vrule height\@GALOISarrowheight width\@GALOISwidth depth0pt}%
% put gamma head
\setlength{\@tempdimb}{\@GALOISalphadepth}
\addtolength{\@tempdimb}{\@GALOISalphaheight}%
\addtolength{\@tempdimb}{\GaloisSep}%
\addtolength{\@tempdimb}{\@GALOISGap}%
\addtolength{\@tempdimb}{\@GALOISarrowheight}% height of alpha arrow
\addtolength{\@tempdimb}{-\@GALOISgammaarrowhalfheight}%
\Galois@put(0pt,\@tempdimb-\@GALOISdepth){${#4}$}%
% put alpha
\setlength{\@tempdima}{\@GALOISwidth}%
\settowidth{\@tempdimb}{$\GaloisStyle#1$}%
\addtolength{\@tempdima}{-\@tempdimb}%
\divide\@tempdima by 2%
\Galois@put(\@tempdima,\@GALOISalphadepth-\@GALOISdepth){$\GaloisStyle#1$}%
% put gamma
\@tempdima\@GALOISwidth%
\settowidth{\@tempdimb}{$\GaloisStyle#2$}%
\addtolength{\@tempdima}{-\@tempdimb}%
\divide\@tempdima by 2%
\@tempdimb\@GALOISalphadepth%
\addtolength{\@tempdimb}{\@GALOISalphaheight}%
\addtolength{\@tempdimb}{2\GaloisSep}%
\addtolength{\@tempdimb}{\@GALOISGap}%
\addtolength{\@tempdimb}{\@GALOISarrowheight}% height of alpha & gamma arrows
\addtolength{\@tempdimb}{\@GALOISarrowheight}% height of alpha & gamma arrows
\addtolength{\@tempdimb}{\@GALOISgammadepth}%
\Galois@put(\@tempdima,\@tempdimb-\@GALOISdepth){$\GaloisStyle#2$}%
\rule[-\@GALOISdepth]{0pt}{\@GALOIStotalheight}% set depth and height
\hspace*{\@GALOISwidth}% set width
}}}%
%
%                       g            
%                   <---------
% \galois{a}{g}  =  --------->
%                       a
%
\newcommand{\galois}[2]{\@GALOIS{#1}{#2}{\longrightarrow}{\longleftarrow}}
%
%                       g
%                   <---------
% \galoiS{a}{g}  =  -------->>   (a onto, g one-to-one, a o g = 1)
%                       a
%
\def\@GALOISmytwoheadrightarrow{\rlap{$\:\,{\rightarrow}$}{\longrightarrow}}
\def\@GALOIStwoheadrightarrow{\protect\@GALOISmytwoheadrightarrow}
\newcommand{\galoiS}[2]{\@GALOIS{#1}{#2}{\@GALOIStwoheadrightarrow}{\longleftarrow}}
%
%                       g
%                   <<--------
% \Galois{a}{g}  =  --------->   (a one-to-one, g onto, g o a = 1)
%                       a
%
\def\@GALOISmytwoheadleftarrow{\rlap{$\:{\leftarrow}$}{\longleftarrow}}
\def\@GALOIStwoheadleftarrow{\protect\@GALOISmytwoheadleftarrow}
\newcommand{\Galois}[2]{\@GALOIS{#1}{#2}{\longrightarrow}{\@GALOIStwoheadleftarrow}}
%
%                       g
%                   <<-------            -1
% \GaloiS{a}{g}  =  -------->>     (a = g  )
%                       a
%
\newcommand{\GaloiS}[2]{\@GALOIS{#1}{#2}{\@GALOIStwoheadrightarrow}{\@GALOISmytwoheadleftarrow}}
%

